#define ElemType int

typedef struct ListNode List_Node;

#include "common.h"

int* productExceptSelf(int* nums, int numsSize, int* returnSize);

int main()
{
	return 0;
}

/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int* productExceptSelf(int* nums, int numsSize, int* returnSize)
{
	*returnSize = numsSize;
	int* res = calloc(numsSize, sizeof(int));

	res[0] = 1;
	for (int i = 1; i < numsSize; i++)
		res[i] = res[i - 1] * nums[i - 1];

	for (int i = numsSize - 2, temp = 1; i >= 0; i--) {
		temp *= nums[i + 1];
		res[i] *= temp;
	}

	return res;
}
